package cn.lzb.book.server.component.convert;

import cn.lzb.book.server.dao.po.BookPo;
import cn.lzb.book.server.entity.dto.BookInfo;
import cn.lzb.book.server.entity.vo.BookDetailVo;
import cn.lzb.book.server.entity.vo.BookPageVo;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

/**
 * @author liuzhibo
 * @date 2024/8/28 17:39
 **/
@Mapper
public interface BookConvert {
    BookConvert INSTANCE = Mappers.getMapper(BookConvert.class);

    @Mappings({
            @Mapping(target = "id", expression = "java(bookPo.getId().toString())")
    })
    BookInfo bookPo2Info(BookPo bookPo);

    BookPo bookInfo2Po(BookInfo bookInfo);

    @Mappings({
            @Mapping(target = "id", expression = "java(bookPo.getId().toString())")
    })
    BookDetailVo bookPo2DetailVo(BookPo bookPo);

    @Mappings({
            @Mapping(target = "id", expression = "java(bookPo.getId().toString())")
    })
    BookPageVo bookPo2PageVo(BookPo bookPo);

}
